﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HOASIS.IU.Formularios.Citas
{
    public partial class Citas : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            llenarGrid();
        }
        WCFMetodos.Service1Client Ser = new WCFMetodos.Service1Client();
        public void llenarGrid()
        {
            DataSet ds = new DataSet();
            string cedula = Session["Cedula"].ToString();
            Ser.llenarGridCitas(cedula, ref ds);
            GdvCitas.DataSource = ds;
            GdvCitas.DataBind();
        }

    
        protected void CancelarCita(object sender, EventArgs e)
        {
            string[] commandArgs = (sender as LinkButton).CommandArgument.ToString().Split(new char[] { ',' });
            int Consecutivo = Convert.ToInt16(commandArgs[0]);
            String EstadoCita = commandArgs[1];
            if (EstadoCita == "Activa")
            {
                DataSet ds = new DataSet();
                string cedula = Session["Cedula"].ToString();
                Ser.CancelarCitas(Consecutivo, ref ds);
                llenarGrid();
            }
        }
        protected void ReprogramarCita(object sender, EventArgs e)
        {
            string[] commandArgs = (sender as LinkButton).CommandArgument.ToString().Split(new char[] { ',' });
            int Consecutivo = Convert.ToInt16(commandArgs[0]);
            String EstadoCita = commandArgs[1];
            if (EstadoCita == "Activa")
            {
                DataSet ds = new DataSet();
                string cedula = Session["Cedula"].ToString();
                Ser.ReprogramarCitas(Consecutivo, ref ds);
                llenarGrid();
            }
        }
        protected void IbtnBuscar_Click(object sender, ImageClickEventArgs e)
        {
            //DataSet ds = new DataSet();
            //string cedula = Session["Cedula"].ToString();
            //Ser.LlenarGrillaMedicamentos(TxtFechaCita.Text, cedula, ref ds);
            //if (ds.Tables[0].Rows.Count > 0)
            //{
            //    GdvCitas.DataSource = ds;
            //    GdvCitas.DataBind();
            //}
            //else
            //{
            //    llenarGrid();
            //}
        }
    }
}